<?php
defined('BASEPATH') OR exit('No direct script access allowed');
 
class Invite extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	 var $dbmain;
     function __construct()
	 {
		    parent::__construct();
            include_once "func.php";
            $this->dbmain = $db;
 	 } 


	public function index()
	{
   
        $data = array(
 		);
  
		ajax_return($data);
	}


	public function getlist(){

		$pageno = 1;
		if(isset($_GET['page_no'])){
			$pageno = $_GET['page_no'];
		}
		$pagesize = 10 ;
  	 	$rs_number = ($pageno - 1) * $pagesize ;


		$sql = "select a.*,a.id as invite_id,b.nickname,b.thumb,b.height,b.sex from invite a,member b where a.member_id=b.id order by a.id desc limit $rs_number,$pagesize";
		$inviteList = $this->dbmain->get_results($sql);
		$count = count($inviteList);
 
        $data = array(
			'invite_list' => $inviteList,
			'count' => $count,
			'page_no' => $pageno,
			'stype' => 'all'
		);
  
		ajax_return($data);
	}

	public function detail(){

		if(!isset($_GET["id"])){
			exit;
		}

	 	$inviteid = $_GET["id"];
	 	$sql = "select a.*,a.id as invite_id,b.nickname,b.thumb,b.height,b.sex from invite a,member b where a.member_id=b.id and a.id='$inviteid'";
 	 	$invite = $this->dbmain->get_row($sql);

 	 	$invite_id = $invite->id;
 	 	$sql = "select a.*,a.id as invite_replay_id,b.nickname,b.thumb from invite_reply a,member b where a.member_id=b.id and a.invite_id='$invite_id'";
		$replys = $this->dbmain->get_results($sql);
		if(!$replys){
			$replys = '';
		}

        $data = array(
			'invite' => $invite,
			'replys' => $replys
		);
  
		ajax_return($data);
	}



    
 
 

    

   



 
 

 
}
